/**
 * @file    array_binary_ops.h
 * @author  Ying-Po Liao <lrobin@neo.tamu.edu>
 * @version 1.0
 *
 * @section This file includes 1) all binary operator classes
 *	    2) all binary logical operator classes
 *
 * CSCE-689 Design Using C++
 * Final Project
 */

#ifndef ARRAY_BINARY_OPS_H
#define ARRAY_BINARY_OPS_H

namespace array_binary_ops
{
	#define DECLARE_ARRAY_BINARY_OPS( name, op )		\
	struct name						\
	{							\
		template <class in_iter, class out_iter>	\
		static inline void apply( out_iter dest, in_iter src )	\
			{ *dest op *src; }			\
	};							\
	
	DECLARE_ARRAY_BINARY_OPS( equal, = );
	DECLARE_ARRAY_BINARY_OPS( plus_equal, += );
	DECLARE_ARRAY_BINARY_OPS( minus_equal, -= );
	DECLARE_ARRAY_BINARY_OPS( multiply_equal, *= );
	DECLARE_ARRAY_BINARY_OPS( divide_equal, /= );
	DECLARE_ARRAY_BINARY_OPS( mod_equal, %= );
	DECLARE_ARRAY_BINARY_OPS( xor_equal, ^= );
	DECLARE_ARRAY_BINARY_OPS( bitand_equal, &= );
	DECLARE_ARRAY_BINARY_OPS( bitor_equal, |= );
	DECLARE_ARRAY_BINARY_OPS( right_shift_equal, >>= );
	DECLARE_ARRAY_BINARY_OPS( left_shift_equal, <<= );
};

namespace array_binary_logical_ops
{
	#define DECLARE_ARRAY_BINARY_LOGICAL_OPS( name, op )	\
	struct name						\
	{							\
		template <class in_iter, class out_iter>	\
		static inline bool apply( out_iter dest, in_iter src )	\
			{ return *dest op *src; }		\
	};							\
	
	DECLARE_ARRAY_BINARY_LOGICAL_OPS( equal, == );
	DECLARE_ARRAY_BINARY_LOGICAL_OPS( not_equal, != );
	DECLARE_ARRAY_BINARY_LOGICAL_OPS( greater, > );
	DECLARE_ARRAY_BINARY_LOGICAL_OPS( less, < );
	DECLARE_ARRAY_BINARY_LOGICAL_OPS( greater_equal, >= );
	DECLARE_ARRAY_BINARY_LOGICAL_OPS( less_equal, <= );
};
#endif //!< ARRAY_BINARY_OPS_H